<?php

namespace App\Providers;

use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider {
  /**
   * Bootstrap any application services.
   *
   * @return void
   */
  public function boot() {
    //
    Validator::extend( 'eq', function ( $attribute, $value, $parameters, $validator ) {
      if ( ! $parameters && is_array( $parameters ) ) {
        return false;
      }

      return $value == $parameters[0];
    } );

    Validator::extend( 'password', function ( $attribute, $value, $parameters, $validator ) {
      if ( ! $parameters && is_array( $parameters ) ) {
        return false;
      }

      return \Hash::check( $value, $parameters[0] );
    } );
  }

  /**
   * Register any application services.
   *
   * @return void
   */
  public function register() {
    Schema::defaultStringLength( 160 );
    //
  }
}
